package main

import (
	"go.uber.org/zap"
	"log"
	"signature-service/config"
	"signature-service/global"
	"signature-service/router"
	"signature-service/utils"
)

func init() {
	global.DBName = "sign"                                                                   // 测试
	global.DBConnect = "mongodb://sign:eJeLd76pm5dE6hiJ@8.218.240.71:27017/?authSource=sign" // 测试
	//global.DBConnect = "mongodb://sign:jJGEjhxAGEipjn4K@127.0.0.1:27017/?authSource=sign" // 生产

	config.SetupMongoDBEngine()
	// 10:ff:e0:65:a4:7e
	// 中国芯 00:16:3e:0d:7c:54
	//utils.CheckAuthorization("00:16:3e:0d:7c:54") // 正式
	utils.CheckAuthorization("10:ff:e0:65:a4:7e") // 测试
}

func main() {
	// 创建 zap.Logger
	logger, err := zap.NewProduction()
	if err != nil {
		log.Fatalf("Failed to initialize logger: %v", err)
	}
	defer func(logger *zap.Logger) {
		err := logger.Sync()
		if err != nil {
			log.Printf(err.Error())
		}
	}(logger) // 确保所有缓冲区中的日志写入

	logo := `
	无人扶我青云志, 我自踏雪之山巅。
	  __          _________ __         .__                
	_/  |_  ____ /   _____//  |________|__| ____    ____  
	\   __\/  _ \\_____  \\   __\_  __ \  |/    \  / ___\ 
	 |  | (  <_> )        \|  |  |  | \/  |   |  \/ /_/  >
	 |__|  \____/_______  /|__|  |__|  |__|___|  /\___  / 
						\/                     \//_____/  
						
	`
	log.Println(logo)
	r := router.RegisterRoute(logger)
	err = r.Run(":8888")
	if err != nil {
		log.Printf(err.Error())
	}
}
